<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="icon" href="favicon.ico" type="image/x-icon"/>
<title>新闻列表-新闻管理-{$site("BACK_NAME")}</title>
<include file="Public:jscss"/>
</head>
<body>
<div class="wrap">
 <include file="Public:head"/>
 <div class="mainBody">
  <include file="Public:left"/>
  <div id="Right">
   <div class="Item hr">
    <div class="current">文章列表</div>
   </div>
   <form action="" method="post" id="quickForm">
    <b>快速搜索：</b>&nbsp;
    <input placeholder="请输入关键字" id="kwd" class="input" type="text" name="kwd" value="{$v_kwd}"/> &nbsp;
	<input type="submit" class="btn quickSubmit" value='搜索'/>
   </form>
   <form action="" method="post" id="tab_form">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tab">
     <thead>
      <tr>
	   <td width="10%"><label><input name="" class="cfz_choose_all" type="checkbox"/> 全选</label><br/><label><input name="" class="cfz_unset_all" type="checkbox"/> 反选</label></td>
       <td width="40%">新闻标题</td>
       <td width="7%">所在分类</td>
       <td width="6%">文章状态</td>
       <td width="12%">发布时间</td>
       <td width="7%">发布人</td>
       <td width="28%">操作</td>
      </tr>
     </thead>
     <foreach name="v_newss" item="news">
     <tr align="center" id='tr_{$news("id")}'>
	  <td><input type="checkbox" name="id[]" value='{$news("id")}'/></td>
      <td align="left">
	   [ <a href='/?m=Admin&c=News&a=comment&id={$news("id")}'><span id='cnum_{$news("id")}'>{$news("total_cnum")}</span>评论 </a> ]
	   [ <a href='/?m=Admin&c=News&a=comment&id={$news("id")}'><span id='pnum_{$news("id")}'>{$news("total_pnum")}</span>赞 </a> ]
	   <neq name="$news(~re_score~)" value="0">
	   <switch name="$news(~reward~)">
	   <case value="0">
	   <font color="block">[悬赏中]</font>
	   </case>
	   <case value="1">
	   <font color="green">[已结算]</font>
	   </case>
	   <default/>
       <font color="red">[悬赏异常]</font>
	   </switch>
	   </neq>
	   {$news("title")}
	  </td>
      <td>{$news("cate_name")}</td>
      <td>
	   <switch name="$news(~status~)">
	   <case value="0">
	   <font color="block">审核中</font>
	   </case>
	   <case value="1">
	   <font color="green">已发布</font>
	   </case>
	   <default/>
	   <font color="red">状态未知</font>
	   </switch>
	  </td>
      <td>{$news("add_time")}</td>
      <td align="left">{$news("u_realname")}</td>
      <td>
	   [
	   <a href="javascript:void(0);" data-val="{$news(~my_pid~)}" class="cfz_praise">
	   <eq name="$news(~my_pid~)" value="0">
	   加赞
	   <else/>
	   <font color="red">去赞</font>
	   </eq>
	   </a>
	   ]
	   [
	   <a href="javascript:void(0);" data-val="{$news(~is_elite~)}" class="cfz_elite">
	   <eq name="$news(~is_elite~)" value="0">
	   精华
	   <else/>
	   <font color="red">去精</font>
	   </eq>
	   </a>
	   ]
	   [
	   <a href="javascript:void(0);" data-val="{$news(~is_top~)}" class="cfz_top">
	   <eq name="$news(~is_top~)" value="0">
	   置顶
	   <else/>
	   <font color="red">去顶</font>
	   </eq>
	   </a>
	   ]
	   [ <a href='/?m=Admin&c=News&a=edt&id={$news("id")}'>编辑 </a> ]
	   [ <a link="{$news(~id~)}" href="javascript:void(0)" name="{$news(~title~)}" class="cfz_del">删除 </a> ]
	  </td>
     </tr>
     </foreach>
    </table>
   </form>
   <div class="viciao">{$v_pager}</div>
   <div class="commonBtnArea">
    <button class="btn cfz_submit">删除所选</button>
   </div>
  </div>
 </div>
</div>
<div class="clear"></div>
<include file="Public:foot"/>
</body>
<script type="text/javascript">
$(function(){
	//快捷加赞去赞
	$(".cfz_praise").click(function(){
		var obj = $(this);
		var id = $(this).parents("tr").attr("id");
		//新闻ID
		id = id.replace("tr_","");
		//赞ID
		var val = $(this).data("val");
		$.getJSON("/?m=Admin&c=News&a=praise", { nid:id, pid:val }, function(json){
			if(json.errcode==0){
				$(obj).data("val",json.data.pid).html(val == 0 ? "<font color='red'>去赞</font>":"加赞");
				if(val == 0){
					//添加
					$("#pnum_" + id).html(parseInt($("#pnum_" + id).html()) + 1);
				}else{
					//取消
					$("#pnum_" + id).html(parseInt($("#pnum_" + id).html()) - 1);
				}
				$.jBox.tip(json.errmsg, 'info');			
			}else{
				$.jBox.tip(json.errmsg, 'error');
			}
		});
	});
	//快捷加精去精
	$(".cfz_elite").click(function(){
		var obj = $(this);
		var id = $(this).parents("tr").attr("id");
		//新闻ID
		id = id.replace("tr_","");
		var val = $(this).data("val");
		$.getJSON("/?m=Admin&c=News&a=elite", { id:id, is_elite:val }, function(json){
			if(json.errcode==0){
				$(obj).data("val",json.data.is_elite).html(val == 0 ? "<font color='red'>去精</font>":"精华");
				$.jBox.tip(json.errmsg, 'info');			
			}else{
				$.jBox.alert(json.errmsg, '提示信息');
			}
		});
	});
	//快捷置顶去顶
	$(".cfz_top").click(function(){
		var obj = $(this);
		var id = $(this).parents("tr").attr("id");
		//新闻ID
		id = id.replace("tr_","");
		var val = $(this).data("val");
		$.getJSON("/?m=Admin&c=News&a=top", { id:id, is_top:val }, function(json){
			if(json.errcode==0){
				$(obj).data("val",json.data.is_top).html(val == 0 ? "<font color='red'>去顶</font>":"置顶");
				$.jBox.tip(json.errmsg, 'info');
				setTimeout(function(){
                    top.window.location.href = "{:U('News/index')}";
                },1500);
			}else{
				$.jBox.alert(json.errmsg, '提示信息');
			}
		});
	});
	//单个删除
	$(".cfz_del").click(function(){
		if($(this).data("busy") == 1){
			$.jBox.tip('已提交，系统在处理中...', 'info');
			return false;
		}
		var news_id = $(this).attr("link");
		$.jBox.confirm(
			'您真的打算删除【<b>'+$(this).attr("name")+'</b>】吗?',
			"温馨提示",
			function(v, h, f) {
				if(v == 'ok'){
					$(".del[link='"+news_id+"']").data("busy",1).html("删除中...");
					$.getJSON("/?m=Admin&c=News&a=del", {id:news_id}, function(json){
						if(json.errcode==0){
							$("#tr_"+news_id).remove();
							$.jBox.tip(json.errmsg, 'success');
						}else{
							$.jBox.tip(json.errmsg, 'error');
						}
					});
					$.jBox.tip("系统处理中，请稍候....", 'loading');
					return true;
				}
			}
		);	
	});
	//多个删除
	$(".cfz_submit").click(function(){
		if($(this).data("busy") == 1){
			$.jBox.tip('已提交，系统在处理中...', 'info');
			return false;
		}
		if($("tbody input[type='checkbox']:checked").size()==0){
			$.jBox.tip('请先选择要删除的项', 'info');
			return false;
		}
		$.jBox.confirm(
			'您确定要删除该选定项吗?',
			"温馨提示",
			function(v, h, f) {
				if(v == 'ok'){
					$(".btn").data("busy",1);
					$(this).html("提交处理中...");
					commonAjaxSubmit("/?m=Admin&c=News&a=del", "#tab_form");
				}
			}
		);
		return false;
	});
});
</script>
</html>